package ycl.system.controller;


import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import ycl.system.req.SysRoleReq;
import ycl.common.result.Result;
import ycl.common.base.controller.BaseController;
import ycl.common.models.base.A;
import ycl.system.entity.SysRole;
import ycl.system.res.SysRoleRes;
import ycl.system.service.SysRoleService;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.validation.Valid;

/**
 * <p>
 * 角色 前端控制器
 * </p>
 *
 * @author ycl
 * @since 2022-03-03 11:43:56
 */
@RestController
@RequestMapping("/sys-role")
@Api(tags = "角色")
public class SysRoleController extends BaseController<SysRole, SysRoleReq, SysRoleRes> {

	@Resource
	private SysRoleService sysRoleService;

	@Override
	public Result<Page<SysRoleRes>> pageList(HttpServletRequest request, SysRole sysRole) {
		return Result.success(sysRoleService.pageList(request, sysRole, SysRoleRes.class));
	}

	@Override
	public <E extends SysRoleReq> Result<A> save(HttpServletRequest request, @RequestBody @Valid E e) {
		sysRoleService.save(request, e, SysRole.class);
		return Result.success();
	}

	@Override
	public <E extends SysRoleReq> Result<A> update(HttpServletRequest request, @RequestBody @Valid E e) {
		sysRoleService.update(request, e, SysRole.class);
		return Result.success();
	}

}

